﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Media;
using System.ComponentModel;

namespace GenTheme.Theme
{
    internal class VisualThread : Thread, INotifyPropertyChanged
    {
        public Color VThreadColor
        {
            get
            {
                return ((IThread)this).ThreadColor ?? ((VisualTheme)this.ThemeObject.Row.Theme).Background;
            }
        }

        public VisualThread(Color? c, IThemeObject owner) : base(c, owner)
        {
        }

        public override void SetColor(Color? c)
        {
            base.SetColor(null);
            if (c != ((VisualTheme)this.ThemeObject.Row.Theme).Background)
            {
                base.SetColor(c);
            }
            this.OnPropertyChanged("VThreadColor");
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }
    }
}
